package com.sn.socket.controller;

import com.sn.socket.config.ResultEnum;
import com.sn.socket.service.OperationService;
import com.sn.socket.utils.SockServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.LinkedBlockingDeque;

/**
 * @ProjectName: springboot_socket
 * @Package: com.sn.socket.controller
 * @ClassName: ${CLASS_NAME}
 * @Author: xiahuihui
 * @Description: ${description}
 * @Date: 2020/5/12 0012 9:53
 * @Version: 1.0
 */
@CrossOrigin
@RestController
@RequestMapping("opera")
public class OperationController {



    @Autowired
    private OperationService operationService;

//    private SockServer sockServer = SockServer.getInstance();


    @PostMapping("device")
    public ResultEnum timelyDevice(@RequestBody Operat operat){


        operationService.timelyTask(operat);


        return ResultEnum.RESULT_SUCCESS;
    }



//    public void addMsgFirst(String deviceId, String cmdString) {
////        SockServer sockServer = SockServer.getInstance();
//        LinkedBlockingDeque deque = sockServer.msgstalble.get(deviceId);
//        if (deque == null) {
//            deque = new LinkedBlockingDeque<String>(100);
//            sockServer.msgstalble.put(deviceId,deque);
//        }
//        deque.offerFirst(cmdString);
//    }

}
